//filter.js 过滤器集合
import common from 'common/js/common'
import orderFilder from 'components/order/filter'
import goodsFilder from 'components/goods/filter'

//定义用的路由集合
var arrFilder = [orderFilder,goodsFilder];

// 公共过滤器
var json = {
		//limitTo过滤器
		limitTo: function(value, num) {
			var text = "";
			if (value) {
				if (value.length < num) {
					text = value;
				} else {
					text = value.substring(0, num) + '···';
				}
			}
			return text;
		},
		// 图片地址过滤器
		imgBaseUrl(img){
			if(!img) return require('common/images/empty.png');
			if(img.indexOf('http:')!==-1||img.indexOf('HTTP:')!==-1){
				return img;
			}else{
				return config.imgBaseUrl+img;
			}
		},
	}
	//合并过滤器
for (var i = 0; i < arrFilder.length; i++) {
	json = common.extend(json, arrFilder[i]);
};

module.exports = json;